package com.xxx.shetuan3.dao;

import com.xxx.shetuan3.pojo.Organization;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface OrganizationDao {
    @Insert("insert into organization " +
            "(organization_name,organization_describe,start,chief_id) " +
            "values(#{organizationName},#{organizationDescribe},#{start},#{chiefId})"
    )
    public boolean saveOrganization(Organization organization);

    @Select("select organization_id organizationId,organization_describe organizationDescribe,organization_name organizationName,start,end,chief_id chiefId " +
            "from organization " +
            "where organization_id = #{organizationId}")
    public Organization findOrganizationById(Integer organizationId);


    @Update("update organization " +
            "set organization_name=#{organizationName},organization_describe = #{organizationDescribe}, end=#{end},chief_id=#{chiefId} " +
            "where organization_id = #{organizationId}" )
    public boolean updateOrganization(Organization organization);

    @Delete("delete from organization where organization_id=#{organizationId}")
    public boolean deleteOrganizationById(Integer organizationId);

    @Select("select organization_id organizationId,organization_name organizationName,organization_describe organizationDescribe, start,end,chief_id chiefId from organization")
    List<Organization> findAll();

    @Select("select organization_id organizationId,organization_name organizationName,organization_describe organizationDescribe, start,end,chief_id chiefId " +
            "from organization " +
            "where chief_id=#{chiefId}")
    public List<Organization> findByChiefId(Integer chiefId);
}

